package com.yc.thread;

/**
 * ThreadLocal里的离散“增量魔数”
 * @author yuancan
 *
 */
public class TestMagicHash {
	
	private final int HASH_INCREMENT = 0x61c88647; 

	public static void main(String[] args) {
		TestMagicHash tm = new TestMagicHash();
		tm.m(16);
		tm.m(32);
	}
	
	public void m(int size) {
		int hashcode = 0;
		for (int i = 0; i < size; i++) {
			hashcode = i * HASH_INCREMENT + HASH_INCREMENT;
			System.out.print((hashcode & (size -1)) + "  ");
		}
		System.out.println();
	}

}
